package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Sign;
import cn.wolfcode.trip.base.service.ISignService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("signs")
public class SignController {

    @Autowired
    private ISignService signService;

    @GetMapping("/{id}")
    public Object  CheckSignByUserId(@PathVariable Long id){
        return signService.CheckSignByUserId(id);
    }


    @GetMapping("/{id}/signcount")
    public Object getSigncountByUserId(@PathVariable Long id){
        return signService.getSigncountByUserId(id);
    }

    @PostMapping
    public JSONResult saveOrUpdate(Sign sign){
        JSONResult result = new JSONResult();
        try {
            signService.saveOrUpdate(sign);
        } catch (Exception e) {
            result.mark(e.getMessage());
        }
        return result;
    }

}
